package dao.impl;

import dao.CommentDao;
import pojo.Comment;

import java.sql.SQLException;
import java.util.List;

public class CommentDaoImpl extends BaseDao implements CommentDao {
    @Override
    public int saveComment(Comment comment) throws SQLException {
        String sql = "insert into comment values(?,?,?,?,?,?,?)";
        return update(sql,comment.getCid(),comment.isLoginpass(),comment.getEmoj(),comment.getText(),comment.getEmojassert(),comment.getTextassert(),comment.isPass());
    }

    @Override
    public List<Comment> getALlComment() throws SQLException {
        String sql = "select * from comment";
        return queryForList(Comment.class,sql);
    }

    @Override
    public Comment getOneComment(String cid) throws SQLException {
        String sql = "select * from comment where cid = ?";
        return queryForOne(Comment.class,sql,cid);
    }
}
